'''
@-*- coding: utf-8 -*-
@ python:python 3.9
@ 创建人员:allen
@ 创建时间:2024/8/30
'''

#API_KEY
#set DASHSCOPE_API_KEY= sk-483aadf1195e4f4da06ef492881516fc

from http import HTTPStatus
import dashscope

dashscope.api_key="sk-483aadf1195e4f4da06ef492881516fc"

def call_with_messages():
    messages = [ {'role': 'user', 'content': '你好'}]

    response = dashscope.Generation.call(
        dashscope.Generation.Models.qwen_turbo,
        messages=messages,
        result_format='message',  # 将返回结果格式设置为 message
    )
    if response.status_code == HTTPStatus.OK:
        print(response)
    else:
        print('Request id: %s, Status code: %s, error code: %s, error message: %s' % (
            response.request_id, response.status_code,
            response.code, response.message
        ))


if __name__ == '__main__':
    call_with_messages()


